﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataEquipmentAlarmItem" @search="()=>{getTableDataEquipmentAlarmItem();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EquipName_FormItem" prop="EquipName" :label="$t('message.autotrans._Model_EquipmentAlarmItem_EquipName')">
            <el-input v-model="searchDataEquipmentAlarmItem.EquipName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EquipTagId_FormItem" prop="EquipTagId" :label="$t('message.autotrans._Model_EquipmentAlarmItem_EquipTag')">
            <el-select v-model="searchDataEquipmentAlarmItem.EquipTagId" clearable>
               <el-option v-for="item in stateEquipmentAlarmItem.AllEquipTags" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EquipTagName_FormItem" prop="EquipTagName" :label="$t('message.autotrans._Model_EquipmentAlarmItem_EquipTagName')">
            <el-input v-model="searchDataEquipmentAlarmItem.EquipTagName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EquipTagAddress_FormItem" prop="EquipTagAddress" :label="$t('message.autotrans._Model_EquipmentAlarmItem_EquipTagAddress')">
            <el-input v-model="searchDataEquipmentAlarmItem.EquipTagAddress" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Content_FormItem" prop="Content" :label="$t('message.autotrans._Model_EquipmentAlarmItem_Content')">
            <el-input v-model="searchDataEquipmentAlarmItem.Content" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Level_FormItem" prop="Level" :label="$t('message.autotrans._Model_EquipmentAlarmItem_Level')">
            <el-select v-model="searchDataEquipmentAlarmItem.Level" clearable>
               <el-option key="L1" value="L1" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L1')"></el-option>
               <el-option key="L2" value="L2" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L2')"></el-option>
               <el-option key="L3" value="L3" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L3')"></el-option>
               <el-option key="L4" value="L4" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L4')"></el-option>
               <el-option key="L5" value="L5" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L5')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Classify_FormItem" prop="Classify" :label="$t('message.autotrans._Model_EquipmentAlarmItem_Classify')">
            <el-select v-model="searchDataEquipmentAlarmItem.Classify" clearable>
               <el-option key="Robot" value="Robot" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Robot')"></el-option>
               <el-option key="EStop" value="EStop" :label="$t('message.autotrans._Enum_AlarmTypeEnum_EStop')"></el-option>
               <el-option key="SensorOver" value="SensorOver" :label="$t('message.autotrans._Enum_AlarmTypeEnum_SensorOver')"></el-option>
               <el-option key="Cylinder" value="Cylinder" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Cylinder')"></el-option>
               <el-option key="Raster" value="Raster" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Raster')"></el-option>
               <el-option key="Welder" value="Welder" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Welder')"></el-option>
               <el-option key="Servo" value="Servo" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Servo')"></el-option>
               <el-option key="Welding" value="Welding" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Welding')"></el-option>
               <el-option key="Vision" value="Vision" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Vision')"></el-option>
               <el-option key="Airtight" value="Airtight" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Airtight')"></el-option>
               <el-option key="General" value="General" :label="$t('message.autotrans._Enum_AlarmTypeEnum_General')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Bits_FormItem" prop="Bits" :label="$t('message.autotrans._Model_EquipmentAlarmItem_Bits')">
            <el-input v-model="searchDataEquipmentAlarmItem.Bits" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Active_FormItem" prop="Active" :label="$t('message.autotrans._Model_EquipmentAlarmItem_Active')">
            <el-select v-model="searchDataEquipmentAlarmItem.Active" clearable>
               <el-option :key="1" :value=true :label="$t('message._system.common.vm.tips_bool_true')"></el-option>
               <el-option :key="0" :value=false :label="$t('message._system.common.vm.tips_bool_false')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateTime_FormItem" prop="CreateTime" :label="$t('message.autotrans._Model_EquipmentAlarmItem_CreateTime')">
            <el-date-picker v-model="searchDataEquipmentAlarmItem.CreateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateTime_FormItem" prop="UpdateTime" :label="$t('message.autotrans._Model_EquipmentAlarmItem_UpdateTime')">
            <el-date-picker v-model="searchDataEquipmentAlarmItem.UpdateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateBy_FormItem" prop="CreateBy" :label="$t('message.autotrans._Model_EquipmentAlarmItem_CreateBy')">
            <el-input v-model="searchDataEquipmentAlarmItem.CreateBy" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateBy_FormItem" prop="UpdateBy" :label="$t('message.autotrans._Model_EquipmentAlarmItem_UpdateBy')">
            <el-input v-model="searchDataEquipmentAlarmItem.UpdateBy" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/EquipmentManagement/EquipmentAlarmItem/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipmentAlarmItem/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipmentAlarmItem/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipmentAlarmItem/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipmentAlarmItem/EquipmentAlarmItemExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefEquipmentAlarmItem" v-bind="tableDataEquipmentAlarmItem">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/EquipmentManagement/EquipmentAlarmItem/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/EquipmentManagement/EquipmentAlarmItem/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/EquipmentManagement/EquipmentAlarmItem/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageEquipmentManagementEquipmentAlarmItemIndex;true;Digitalmes.EquipmentManagement.Controllers;EquipmentAlarmItem">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { equipmentalarmitemApi } from '/@/api/equipmentmanagement/equipmentalarmitem';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateEquipmentAlarmItem = reactive({
    
    AllEquipTags: [] as any[],
});

const searchDataEquipmentAlarmItem = ref({
        EquipName: '',
        EquipTagId: null,
        EquipTagName: '',
        EquipTagAddress: '',
        Content: '',
        Level: undefined,
        Classify: undefined,
        Bits: null,
        Active: undefined,
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
});

// 定义变量内容
const tableRefEquipmentAlarmItem = ref();
const tableDataEquipmentAlarmItem = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page设备名称'),key: 'EquipmentAlarmItem_EquipName',type: 'text',isCheck: true},
    
    //   {title:ci.proxy.$t('message.autotrans.Page关联设备'),key: 'EquipmentAlarmItem_EquipmentId',type: 'text',isCheck: true},
    //   {title:ci.proxy.$t('message.autotrans.Page变量名称'),key: 'EquipmentAlarmItem_EquipTagName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page变量地址'),key: 'EquipmentAlarmItem_EquipTagAddress',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page报警内容'),key: 'EquipmentAlarmItem_Content',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page报警级别'),key: 'EquipmentAlarmItem_Level',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page报警分类'),key: 'EquipmentAlarmItem_Classify',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page位'),key: 'EquipmentAlarmItem_Bits',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page激活'),key: 'EquipmentAlarmItem_Active',type: 'switch',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateTime'),key: 'EquipmentAlarmItem_CreateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateTime'),key: 'EquipmentAlarmItem_UpdateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateBy'),key: 'EquipmentAlarmItem_CreateBy',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateBy'),key: 'EquipmentAlarmItem_UpdateBy',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataEquipmentAlarmItem = () => {
    tableRefEquipmentAlarmItem.value.doSearch(equipmentalarmitemApi().search, searchDataEquipmentAlarmItem.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataEquipmentAlarmItem)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataEquipmentAlarmItem)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataEquipmentAlarmItem)
};

// 删除
const onDelete = (row: any) => {
    equipmentalarmitemApi().delete([row.ID]).then(() => { getTableDataEquipmentAlarmItem()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefEquipmentAlarmItem.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      equipmentalarmitemApi().delete(selectedids).then(() => { getTableDataEquipmentAlarmItem()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefEquipmentAlarmItem.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataEquipmentAlarmItem)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataEquipmentAlarmItem)
};

const onExport = () => {
	const selected = tableRefEquipmentAlarmItem.value.getSelectedRows();
	if (selected.length > 0) {
		equipmentalarmitemApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		equipmentalarmitemApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/EquipmentManagement/EquipmentAlarmItem/GetEquipmentTags',[],false).then(x=>{stateEquipmentAlarmItem.AllEquipTags = x});
        getTableDataEquipmentAlarmItem();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

